#! /usr/bin/python
#coding=utf-8

import redis

def redis_invalid_key_del(r, item_name):
    hkeys = r.hkeys(item_name)
    h_key_inv = [i for i in hkeys if i.find('_') > 0]
    for k_inv in h_key_inv:
        print 'del %s in %s' % (k_inv, item_name)
        r.hdel(item_name, k_inv)

if __name__ == '__main__':
    r = redis.Redis(host='127.0.0.1', db=1)
    for item in r.keys('item_*'):
        redis_invalid_key_del(r, item)
    r.save()

